import $axios from '@/utils/request'

export const getCategory = params => {
  return $axios({
    url: '/category',
    method: 'get',
    params
  })
}

export const getTopicList = params => {
  return $axios({
    url: '/topic',
    method: 'get',
    params
  })
}

// 登录
export const login = data => {
  return $axios({
    url: '/user?method=login',
    method: 'post',
    params: data
  })
}

// 退出
export const logout = () => {
  return $axios({
    url: '/user?method=logout',
    method: 'get'
  })
}

// 获取详情
export const getDetail = id => {
  return $axios({
    url: '/topic?method=findDetailById&topicId=' + id,
    method: 'get'
  })
}

// 回复主题
export const addReply = params => {
  return $axios({
    url: `/topic?method=addReplyByTopicId&topic_id=${params.topicId}&content=${params.content}`,
    method: 'get'
  })
}

// 新增主题
export const addTopic = params => {
  return $axios({
    url: `/topic?method=addTopic&cId=${params.categoryId}&title=${params.title}&content=${params.content}`,
    method: 'get'
  })
}
